﻿using System.Reflection;

namespace Yuchen.NPA.Core
{
    public class NPAProxy<T, TEntity> : DispatchProxy, INpaProxy<TEntity>
    {
        public ICommandExecutor<TEntity> CommandExecutor { get; set; }

        protected override object Invoke(MethodInfo targetMethod, object[] args)
        {
            return CommandExecutor.ExecuteAsync(targetMethod, args).Result;
            //if (targetMethod.DeclaringType.IsGenericType && targetMethod.DeclaringType.GetGenericTypeDefinition() == typeof(INpaRepository<>))
            //{
            //    //基类默认的方法
            //    switch (targetMethod.Name)
            //    {
            //        case "FindAll":
            //            CommandExecutor
            //            break;
            //    }
            //}
        }

    }
}
